package gui;

import javax.swing.*;

import java.awt.Font;
import java.awt.event.*;

public class AdminMenu extends JPanel{
	
	private JLabel lblAdminMenu;
	private JRadioButton rdbtnCreateUser;
	private JRadioButton rdbtnDeleteUser;
	private JRadioButton rdbtnViewUsers;
	private final ButtonGroup buttonGroup = new ButtonGroup();
	private JButton btn_Next;
	private JButton btn_Back;
	private String choice;
	
	public AdminMenu() {
		
		setLayout(null);
		
		lblAdminMenu = new JLabel("Administrator Menu");
		lblAdminMenu.setFont(lblAdminMenu.getFont().deriveFont(lblAdminMenu.getFont().getStyle() | Font.BOLD, lblAdminMenu.getFont().getSize() + 6f));
		lblAdminMenu.setBounds(169, 46, 200, 21);
		add(lblAdminMenu);
		
		rdbtnCreateUser = new JRadioButton("Create a new User");
		rdbtnCreateUser.addItemListener(new RadioCreateItemListener());
		buttonGroup.add(rdbtnCreateUser);
		rdbtnCreateUser.setFont(new Font("SansSerif", Font.PLAIN, 14));
		rdbtnCreateUser.setBounds(169, 98, 143, 27);
		add(rdbtnCreateUser);
		
		rdbtnDeleteUser = new JRadioButton("Delete a User");
		rdbtnDeleteUser.addItemListener(new RadioDeleteItemListener());
		buttonGroup.add(rdbtnDeleteUser);
		rdbtnDeleteUser.setFont(new Font("SansSerif", Font.PLAIN, 14));
		rdbtnDeleteUser.setBounds(169, 128, 111, 27);
		add(rdbtnDeleteUser);
		
		rdbtnViewUsers = new JRadioButton("View all Users");
		rdbtnViewUsers.addItemListener(new RadioViewItemListener());
		buttonGroup.add(rdbtnViewUsers);
		rdbtnViewUsers.setFont(new Font("SansSerif", Font.PLAIN, 14));
		rdbtnViewUsers.setBounds(169, 158, 131, 27);
		add(rdbtnViewUsers);
				
		btn_Next = new JButton("Next");
		btn_Next.setBounds(349, 243, 91, 23);
		add(btn_Next);
		
		btn_Back = new JButton("Back");
		btn_Back.setBounds(29, 243, 91, 23);
		add(btn_Back);
	}
		
		public void addActionListener(ActionListener event) {
			btn_Next.addActionListener(event);
			btn_Back.addActionListener(event);
		}
		
		public String getChoice(){
			return choice;
		}
		
		public JButton getBtnNext() {
			return btn_Next;
		}
		
		private class RadioCreateItemListener implements ItemListener {
			public void itemStateChanged(ItemEvent arg0) {
				choice = rdbtnCreateUser.getActionCommand();
			}
		}
		private class RadioViewItemListener implements ItemListener {
			public void itemStateChanged(ItemEvent e) {
				choice = rdbtnDeleteUser.getActionCommand();
			}
		}
		private class RadioDeleteItemListener implements ItemListener {
			public void itemStateChanged(ItemEvent e) {
				choice = rdbtnViewUsers.getActionCommand();
			}
		}
}
